<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">

<head>
    <meta charset="UTF-8">
    <title>首页</title>
    <script type="text/javascript" th:src="@{/js/jquery-3.6.0.min.js}"></script>
    <script src="https://g.alicdn.com/dingding/dingtalk-jsapi/3.0.25/dingtalk.open.js"></script>
    <style>
    </style>
    <script type="text/javascript" th:src="@{/js/authLogin.js}"></script>
</head>

<body>

<div th:fragment="attendance">
    <div>
        你好呀
    </div>
    <div id="userData">
        <div>userName:<span id="userName"></span></div>
        <div>deviceId:<span id="deviceId"></span></div>
        <div>userid:<span id="userid"></span></div>
    </div>

</div>
<script>
    checkLogin("/app/getClockList")
</script>
<!--<script>-->
<!--    const corpIdStr = "ding347b4c4d0e79330a4ac5d6980864d335";-->
<!--    var codeStr = '';-->
<!--    let item = localStorage.getItem('userData');-->
<!--    console.log(item)-->
<!--    item = JSON.parse(item);-->
<!--    if(item == null) {-->
<!--        dd.getAuthCode({-->
<!--            corpId: corpIdStr,-->
<!--            success: (res) => {-->
<!--                const {code} = res;-->
<!--                codeStr = code;-->
<!--                login()-->
<!--            },-->
<!--            fail: () => {-->
<!--            },-->
<!--            complete: () => {-->
<!--            },-->
<!--        });-->
<!--        // codeStr = "8ea4a6ebe8d337db854288f7f0075f5d";-->
<!--        // login();-->
<!--    }else {-->
<!--        getClockList(item.userName);-->
<!--    }-->

<!--    function getClockList(userName){-->
<!--        // location.href = "/attend/getClockList?userName=" + userName;-->
<!--        location.replace("/app/getClockList?userName=" + userName);-->
<!--    }-->
<!--    function login() {-->
<!--        $.ajax({-->
<!--            url: "/dingTalk/login?code=" + codeStr,// 请求的地址-->
<!--            data: {},// 请求参数&#45;&#45;没有-->
<!--            type: "get",// 请求方式-->
<!--            dataType: "json",// 服务器返回的数据类型即为json对象-->
<!--            success: function (resp) {-->
<!--                var userData = resp;-->
<!--                console.log(userData)-->
<!--                console.log(userData.userName)-->
<!--                $('#userName').text(userData.userName);-->
<!--                $('#deviceId').text(userData.deviceId);-->
<!--                $('#userid').text(userData.userid);-->
<!--                localStorage.setItem('userData', JSON.stringify(userData));-->
<!--                getClockList(userData.userName);-->
<!--            },-->
<!--            timeout: 50000,// 超时时间，超时后会调用error后的函数-->
<!--            error: function (xhr, textStatus, errorThrown) {-->
<!--                // 404 请求地址无效-->
<!--                if (XMLHttpRequest.status == '404') {-->
<!--                    alert("404:请求地址" + url + "无效.");-->
<!--                    return;-->
<!--                }-->

<!--                var msg = "xhr.readyState=" + xhr.readyState + "\n";-->
<!--                msg += "xhr.status=" + xhr.status + "\n";-->
<!--                msg += "errorThrown=" + errorThrown + "\n";-->
<!--                alert(msg);-->
<!--            }-->
<!--        });-->
<!--    }-->

<!--</script>-->

</body>

</html>